/**
 * 节流函数
 *
 * @export
 * @param {*} fn  函数
 * @param {*} gapTime   节流时间
 * @returns
 */

function throttle(fn, gapTime) {
  let _lastTime = null;

  return function () {
    let _nowTime = +new Date();
    if (_nowTime - _lastTime > gapTime || !_lastTime) {
      fn();
      _lastTime = _nowTime;
    }
  };
}

let fn = () => {
  console.log("boom");
};

setInterval(throttle(fn, 1000), 10);
